<template>
  <div class="user-body-user">
    <div class="body-content">
      <div class="user-left">
        <el-avatar
          class="left-avatar"
          :size="80"
          :src="userInfo.avatar"
          :icon="UserFilled"
          @click="toPersonalInfo"
        />
      </div>
      <div class="user-right">
        <!-- 姓名 -->
        <span class="name">{{ userInfo.name }}</span>
        <!-- 账号/学号 -->
        <span>
          {{ userInfo.role !== 2 ? userInfo.account : userInfo.stu_num }}&nbsp;&nbsp;
          <el-tag :type="userInfo.role === 0 ? 'warning' : userInfo.role === 1 ? '' : 'success'">
            {{ userInfo.role === 0 ? '管理员' : userInfo.role === 1 ? '教师' : '学生' }}
          </el-tag>
        </span>
        <!-- 联系方式 -->
        <span>{{ userInfo.email }}</span>
        <template v-if="userInfo.role === 2">
          <!-- <span>{{userInfo.major}}</span>
          <span >{{userInfo.class}}</span> -->
        </template>
      </div>
    </div>
    <div class="body-footer">
      <span @click="toPersonalInfo">查看</span>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { UserFilled } from '@element-plus/icons-vue'

const store = useStore()
const router = useRouter()

const userInfo = computed(() => store.state.userModule.userInfo)

const toPersonalInfo = () => {
  router.push('/home/personal/info')
}
</script>

<style lang="less" scoped>
.user-body-user {
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 160px;
  justify-content: space-between;
  .body-content {
    padding: 0 15px;
    display: flex;
    .user-left {
      width: 100px;
      display: flex;
      flex-direction: column;
      .left-avatar {
        cursor: pointer;
      }
    }
    .user-right {
      display: flex;
      flex-direction: column;
      color: #303133;
      span {
        margin-top: 7px;
        font-size: 14px;
      }
    }
  }
  .body-footer {
    width: 100%;
    height: 30px;
    // margin-top: 43px;
    border-top: 1px solid #eee;
    text-align: end;
    span {
      width: 20px;
      padding: 2px 5px;
      border-radius: 5px;
      color: #409eff;
      line-height: 30px;
      font-size: 14px;
      cursor: pointer;
    }
    span:hover {
      background-color: rgb(246, 245, 245);
    }
  }
}
</style>
